#_*_ coding : utf-8 _*_
import threading
from threading import Thread
import time

def fun_print2(convariable, num:int, string:str="__testing__", iinterval:int=4):   
    for i in range(num):
        if convariable.acquire():
            print("i:[{}] -- interval[{}]".format(i, iinterval))
            convariable.notify()
        convariable.wait()
        time.sleep(iinterval)
    convariable.release()    

def fun_print3(convariable, num:int, string:str="__testing__", iinterval:int=3):    
    time.sleep(2)
    for t in range(num):
        if convariable.acquire():
            print("t:[{}] -- interval[{}]".format(t, iinterval))
            convariable.notify()
        convariable.wait()
        time.sleep(iinterval)
    convariable.release()
    
def run_pool():
    convariable = threading.Condition()

    t_args = [(20, 2), (20, 3)]
    # t1 = Thread(target=fun_print2, args=t_args[0])
    # t2 = Thread(target=fun_print3, args=t_args[1])
    t1 = Thread(target=fun_print2, args=(convariable, 20))
    t2 = Thread(target=fun_print3, args=(convariable, 20))

    t1.start()
    t2.start()
    t1.join()
    t2.join()
    convariable.release()

if __name__ == "__main__":
    run_pool()
    print("Hello python")
